package com.hfzy.ihk.web.freeswitchManage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hfzy.ihk.facade.freeswitchManage.entity.Gateway;
import com.hfzy.ihk.facade.userCenter.entity.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author czs
 * @since 2019-03-22
 */
public interface GatewayMapper extends BaseMapper<Gateway> {


    Integer count(@Param("params") Map<String, Object> params);

    List<Gateway> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset,
                        @Param("limit") Integer limit);

    @Select("select * from gateway g where g.num=#{num}")
    Gateway queryGatewayByNum(String num);

    @Update("update gateway set sip_user = #{sipUser}, ip=#{ip},port=#{port} where num=#{num}")
    int updateSipUserAndIpAndPortByNum(@Param("num")String num,@Param("sipUser")String sipUser,@Param("ip")String ip,@Param("port")String port);

    @Select("select * from gateway ORDER BY RAND() LIMIT #{count}")
    List<Gateway> queryRandTwoLimit(@Param("count")int count);

}
